import { PartialType } from '@nestjs/mapped-types'
import { CreateMenuDto } from './create-menu.dto'
import {
  IsEnum,
  IsNotEmpty,
  isNumber,
  IsOptional,
  IsString
} from 'class-validator'
import { Menu } from '../entities/menu.entity'

export class UpdateMenuDto extends PartialType(CreateMenuDto) {
  @IsOptional()
  id: number
  @IsOptional()
  createTime: string
  @IsOptional()
  children?: Array<Menu>
}

export class BindOperationDto {
  @IsOptional()
  readonly menuId: number
  @IsOptional()
  readonly operationCodes: string[]
  constructor(partial: Partial<BindOperationDto>) {
    Object.assign(this, partial)
  }
}
export enum PermissionType {
  GET = 'get',
  POST = 'post',
  DELETE = 'delete',
  PATCH = 'patch'
}
export class UpdateMenuPermissionDto {
  @IsOptional()
  id: number

  @IsOptional()
  menuId: number

  @IsOptional()
  @IsString()
  name?: string

  @IsOptional()
  @IsString()
  description?: string

  @IsOptional()
  @IsString()
  permission?: string

  @IsOptional()
  @IsEnum(PermissionType)
  type?: PermissionType
}
